/*
 * Created on 08.08.2006 by leck
 *
 */
package de.devisnik.eidle.picture;

import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;

import de.devisnik.eidle.EidleActivator;

public class SlideShowPreferences extends AbstractPreferenceInitializer {

	public final static String KEY_GLOBAL_IMAGE_PATH = "global_image_path";
	public final static String KEY_PRESENTATION_TIME = "presentation_time";
	public final static String KEY_ENABLED = "enabled";

	public static void setGlobalImagePath(final String value) {
		getPreferences().setValue(KEY_GLOBAL_IMAGE_PATH, value);
	}

	public static String getGlobalImagePath() {
		final String imagePath = getPreferences().getString(
				KEY_GLOBAL_IMAGE_PATH);
		return imagePath;
	}

	// @Override
	public void initializeDefaultPreferences() {
		getPreferences().setDefault(KEY_GLOBAL_IMAGE_PATH,
				EidleActivator.getDefault().getDataLocation());
		getPreferences().setDefault(KEY_PRESENTATION_TIME, 10);
		getPreferences().setDefault(KEY_ENABLED, true);
	}

	private static Preferences getPreferences() {
		return PictureActivator.getDefault().getPluginPreferences();
	}

	/**
	 * @return the time to present an image (in seconds)
	 */
	public static int getPresentationTime() {
		return getPreferences().getInt(KEY_PRESENTATION_TIME);
	}

	public static void setPresentationTime(final int value) {
		getPreferences().setValue(KEY_PRESENTATION_TIME, value);
	}

	public static boolean isEnabled() {
		return getPreferences().getBoolean(KEY_ENABLED);
	}
}
